{% macro construct_function(property, source) %}
check_{{ property.get_class_name_snake_case() }}({{ source }})
{% endmacro %}

{% from "property_templates/property_macros.py.jinja" import construct_template %}

{% macro construct(property, source) %}
{{ construct_template(construct_function, property, source) }}
{% endmacro %}

{% macro check_type_for_construct(property, source) %}isinstance({{ source }}, {{ property.get_instance_type_string() }}){% endmacro %}

{% macro transform(property, source, destination, declare_type=True, skip_unset=False) %}
{% set type_string = property.get_type_string(json=True) %}
{% if property.required %}
{{ destination }}{% if declare_type %}: {{ type_string }}{% endif %} = {{ source }}
{%- else %}
{% if not skip_unset %}{{ destination }}{% if declare_type %}: {{ type_string }}{% endif %} = UNSET{% endif +%}
if not isinstance({{ source }}, Unset):
    {{ destination }} = {{ source }}
{% endif %}
{% endmacro %}

{% macro multipart(property, source, name) %}
files.append(({{ name }}, (None, str({{ source }}).encode(), "text/plain")))
{% endmacro %}

{% macro transform_header(source) %}
str({{ source }})
{% endmacro %}
